﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BLL;
using System.Text;
using System.Web.Security;
using Model;
namespace OA.Ajax
{
    /// <summary>
    /// CheckHeaderLinkashx 的摘要说明
    /// </summary>
    public class CheckHeaderLinkashx : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {

                context.Response.Write("登录");
                return;
            }
            string RoleId = (HttpContext.Current.User.Identity as FormsIdentity).Ticket.UserData;
            roleInfo RI = new roleInfo();
            roleInfoManager RIManager = new roleInfoManager();
            List<roleInfo> listRole = RIManager.GetAll().ToList();
            if (RoleId == "13")
            {
                RI = listRole[0];
            }
            else
            {
                RI = listRole[1];
            }
            int Query;
            int.TryParse(context.Request.QueryString["id"], out Query);
            if (Query == -1 || Query == 1)
            {
                #region  点击桌面实现左侧栏
                string[] roleInfo1 = RI.roleInfo1.Split(',');
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(" <table style=\" width:150px;\"><tr> <td colspan=\"2\" style='cursor: pointer' class='tabheader'>&nbsp; 会员管理中心</td> </tr></table>");
                sb.AppendLine("<ul>");
                if (roleInfo1[0] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/MemberSale/MemberSale' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/MemberSale/MemberSale' target='main' >会员消费</a></li>");
                }
                if (roleInfo1[1] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/Recharge/Recharge' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/Recharge/Recharge' target='main'>会员充值</a></li>");
                }
                if (roleInfo1[2] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/MemberAdd/MemberAdd' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/MemberAdd/MemberAdd' target='main'>添加会员</a></li>");
                }
                if (roleInfo1[3] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/changeCardPwd/changeCardPwd' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/changeCardPwd/changeCardPwd' target='main'>修改卡密码</a></li>");
                }
                if (roleInfo1[4] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/SelectMember/SelectMember' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a id=\"selectMember\" href='/Loading/Index/?src=/SelectMember/SelectMember'  target='main'>查找会员</a></li>");
                }
                if (roleInfo1[5] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/LostCard/LostCardMain' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/LostCard/LostCardMain' target='main'>挂失办理</a></li>");
                }
                if (roleInfo1[6] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Login/Login' target='_parent'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='#'  onclick=\"parent.location.href='/Login/Login'\">系统锁屏</a></li>");
                }
                if (roleInfo1[7] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/BalanceRemind/BalanceRemind' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/BalanceRemind/BalanceRemind' target='main'>卡金提醒</a></li>");
                }
                if (roleInfo1[8] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/BirthdayRemind/BirthdayRemind' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/BirthdayRemind/BirthdayRemind' target='main'>生日提醒</a></li>");
                }
                if (roleInfo1[9] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/UserManager/UserInfo' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/UserManager/UserInfo' target='main' >用户管理</a></li>");
                }
                if (roleInfo1[10] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/InputToExcel/InputToExcel' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/InputToExcel/InputToExcel' target='main' >批量会员导出</a></li>");
                }
                if (roleInfo1[11] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/Email/SendEmail' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/Email/SendEmail' target='main' >群发邮件</a></li>");
                }
                sb.AppendLine("</ul>");
                context.Response.Write(sb);
                #endregion
            }
            if (Query == 2)
            {
                #region  基本设置
                string[] roleInfo2 = RI.roleInfo2.Split(',');
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("<table style=\" width:150px;\"><tr> <td colspan=\"2\" style='cursor: pointer' class='tabheader'>&nbsp; 基本设置</td> </tr></table>");
                sb.AppendLine("<ul>");
                if (roleInfo2[0] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/CardTemplateDesignMain/CardTemplateDesignMain' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/CardTemplateDesignMain/CardTemplateDesignMain' target='main' >卡面设计</a></li>");
                }
                if (roleInfo2[1] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/ConsumeSolution/ConsumeSolution' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/ConsumeSolution/ConsumeSolution' target='main'>会员等级</a></li>");
                } 
                if (roleInfo2[2] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/Produce/ProduceInfo' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/Produce/ProduceInfo' target='main' >商品设置</a></li>");
                }
                sb.AppendLine("</ul>");
                context.Response.Write(sb);
                #endregion
            }
            if (Query == 3)
            {
                #region  系统设置
                string[] roleInfo3 = RI.roleInfo3.Split(',');
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("<table style=\" width:150px;\"><tr> <td colspan=\"2\" style='cursor: pointer' class='tabheader'>&nbsp; 系统设置</td> </tr></table>");
                sb.AppendLine("<ul>");
                if (roleInfo3[0] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/Operator/Operator' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/Operator/Operator' target='main' >操作员管理</a></li>");
                }
                if (roleInfo3[1] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='Common/Schedule/Schedule.aspx' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='Common/Schedule/Schedule.aspx' target='main'>智能决策管理</a></li>");
                }
                if (roleInfo3[2] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/RollInfo/RollInfo' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/RollInfo/RollInfo' target='main'>角色管理</a></li>");
                }
                sb.AppendLine("</ul>");
                context.Response.Write(sb);
                #endregion
            }
            if (Query == 4)
            {
                #region  查询图表
                string[] roleInfo4 = RI.roleInfo4.Split(',');
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("<table style=\" width:150px;\"><tr> <td colspan=\"2\" style='cursor: pointer' class='tabheader'>&nbsp; 查询图表</td> </tr></table>");
                sb.AppendLine("<ul>");
                if (roleInfo4[0] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='Common/Schedule/Schedule.aspx' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='Common/Schedule/Schedule.aspx' target='main'>客户查询</a></li>");
                }
                if (roleInfo4[1] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/CustomerContributeChart/CustomerContributeChart' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/CustomerContributeChart/CustomerContributeChart' target='main'>用户贡献查询</a></li>");
                }
                if (roleInfo4[2] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='Common/Schedule/Schedule.aspx' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='Common/Schedule/Schedule.aspx' target='main'>商品查询</a></li>");
                }
                if (roleInfo4[3] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/MembercartTypeChart/MembercartTypeChart' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/MembercartTypeChart/MembercartTypeChart' target='main'>会员统计</a></li>");
                }
                if (roleInfo4[4] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/AgeanalyseChart/AgeanalyseChart' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/AgeanalyseChart/AgeanalyseChart' target='main'>年龄分析</a></li>");
                }
                if (roleInfo4[5] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/GoodsChart_two/GoodsChart_two' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/GoodsChart_two/GoodsChart_two' target='main'>商品饼图查询</a></li>");
                }
                sb.AppendLine("</ul>");
                context.Response.Write(sb);
                #endregion
            }
            if (Query == 5)
            {
                #region 收入明细
                string[] roleInfo5 = RI.roleInfo5.Split(',');
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("<table style=\" width:150px;\"><tr> <td colspan=\"2\" style='cursor: pointer' class='tabheader'>&nbsp; 收入明细</td> </tr></table>");
                sb.AppendLine("<ul>");
                if (roleInfo5[0] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/SystemNode/SystemNode' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/SystemNode/SystemNode' target='main'>系统日志</a></li>");
                }
                if (roleInfo5[1] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/User_Productwater/User_Productwater' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/User_Productwater/User_Productwater' target='main'>无卡用户流水</a></li>");
                }
                if (roleInfo5[2] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/ConsumptionBill/ConsumptionBill' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/ConsumptionBill/ConsumptionBill' target='main'>消费流水</a></li>");
                }
                if (roleInfo5[3] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/GoodsFlowing/GoodsFlowing' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/GoodsFlowing/GoodsFlowing' target='main' >商品流水</a></li>");
                }
                if (roleInfo5[4] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='/Loading/Index/?src=/Discount/Discount' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='/Loading/Index/?src=/Discount/Discount' target='main'>折扣查询</a></li>");
                }
                sb.AppendLine("</ul>");
                context.Response.Write(sb);
                #endregion
            }
            if (Query == 6)
            {
                #region   卡片设置

                StringBuilder sb = new StringBuilder();
                string[] roleInfo6 = RI.roleInfo6.Split(',');
                sb.AppendLine(" <table style=\" width:150px;\"><tr onclick='OpenMenu(\"T040\");'> <td colspan=\"2\" style='cursor: pointer' class='tabheader'>&nbsp; 卡片设置</td> </tr></table>");
                sb.AppendLine("<ul>");
                if (roleInfo6[0] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a href='Common/Schedule/Schedule.aspx' target='main'><img  src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='Common/Schedule/Schedule.aspx' target='main'>进卡</a></li>");
                }
                if (roleInfo6[1] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a  href='Common/Schedule/Schedule.aspx' target='main'><img  src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='Common/Schedule/Schedule.aspx' target='main'>出卡</a></li>");
                }
                if (roleInfo6[2] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a  href='Common/Schedule/Schedule.aspx' target='main'><img  src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='Common/Schedule/Schedule.aspx' target='main'>清洗机器</a></li>");
                }
                if (roleInfo6[3] == "1")
                {
                    sb.AppendLine("<li class=\"MenuList\"><a  href='Common/Schedule/Schedule.aspx' target='main'><img src='../../Content/Icon/24005_b.gif' border=\"0\"></a><br/><a href='Common/Schedule/Schedule.aspx' target='main'>删除卡面内容</a></li>");
                }
                sb.AppendLine("</ul>");
                context.Response.Write(sb);
                #endregion
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}